--[[/**
-- * 
/**
 * 且溢出的能量全部转化为冰龙生命值，每 N 点能量可转化 M %冰龙最大生命值。
 *
 * 这个buff,是召唤物给自己主人加的 (这样做是为了, 这个buff触发时,能直接找到这个冰龙)
-- *
-- */]]

---@class BuffEffect572100 : BaseBuffEffect
BuffEffect572100 = ClientFight.CreateClass("BuffEffect572100", ClientFight.BaseBuffEffect)
local t = BuffEffect572100

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    if (buff.target:isSummons()) then
        return IBuffEffect.FAIL;
    end
    if (not buff.source:isSummons()) then
        return IBuffEffect.FAIL;
    end
    local buffEffectValue = buff.buffBean.f_BuffEffectValue;
    local result = parameters[3];
    if (result.damage <= 0) then
        return IBuffEffect.FAIL;
    end
    local energy = buff.target.energy + result.damage;
    if (energy <= buff.target.maxEnergy) then
        return IBuffEffect.FAIL;
    end
    local value = energy - buff.target.getMaxEnergy();--溢出的能量

    local ratio = value / buffEffectValue[1] * buffEffectValue[2];

    if (ratio < 1) then
        return IBuffEffect.FAIL;
    end

    local addHp = Utils.calcRatio(FighterAttributeManager.getFightAttr(buff.source, FighterAttributeEnum.HP), ratio);
    SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]Fighter %s buff%s 没X点能量转化为冰龙的血量, 转化率 %s ,加血= %s ",
            fight.frame, buff.target.fighterId, buff.modelId, ratio, addHp));
    DamageManager.setFighterHp(fight, buff.source, buff.target, nil, DamageResultTypeEnum.HEAL, addHp, buff.source.hp + addHp,
            true, false, true);
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()